// 测试天气显示功能
const axios = require('axios');

async function testWeatherDisplay() {
    console.log('🧪 测试天气显示功能');
    console.log('==================');
    
    try {
        // 测试算命API，应该包含天气信息
        console.log('📤 测试算命API（包含天气）...');
        
        const response = await axios.post('http://localhost:30080/api/fortune', {
            name: '测试用户',
            birthDate: '1990-01-01',
            gender: 'male',
            city: '北京'
        });
        
        console.log('📥 API响应状态:', response.status);
        
        if (response.data.success) {
            const fortune = response.data.data.fortune;
            
            console.log('✅ 算命API调用成功');
            console.log('🔮 运势信息:', fortune.today.substring(0, 50) + '...');
            
            if (fortune.weather) {
                console.log('🌤️  天气信息:');
                console.log('  城市:', fortune.weather.city);
                console.log('  温度:', fortune.weather.temperature + '°C');
                console.log('  天气:', fortune.weather.weather);
                console.log('  温度范围:', `${fortune.weather.temperatureLow}°C ~ ${fortune.weather.temperatureHigh}°C`);
                console.log('  风力风向:', `${fortune.weather.wind} ${fortune.weather.windSpeed}`);
                console.log('  空气质量:', fortune.weather.airQuality);
                console.log('  湿度:', fortune.weather.humidity);
                console.log('  更新时间:', `${fortune.weather.date} ${fortune.weather.updateTime}`);
                
                console.log('\n✅ 天气信息显示正常！');
            } else {
                console.log('❌ 没有天气信息');
            }
        } else {
            console.log('❌ 算命API调用失败:', response.data.error);
        }
        
    } catch (error) {
        console.error('❌ 测试失败:', error.message);
        
        if (error.code === 'ECONNREFUSED') {
            console.log('💡 请确保服务器正在运行: npm run dev');
        }
    }
}

// 运行测试
testWeatherDisplay();